package com.minimalist.basic.config.request;
import org.jetbrains.annotations.NotNull;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpInputMessage;

import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;

class DecryptHttpInputMessage implements HttpInputMessage {
    private final HttpHeaders headers;
    private final InputStream inputStream;

    public DecryptHttpInputMessage(HttpInputMessage inputMessage, String decryptedData) {
        this.headers = inputMessage.getHeaders();
        this.inputStream = new ByteArrayInputStream(decryptedData.getBytes(StandardCharsets.UTF_8));
    }

    @NotNull
    @Override
    public InputStream getBody() {
        return inputStream;
    }

    @NotNull
    @Override
    public HttpHeaders getHeaders() {
        return headers;
    }
}
